package com.study.zgw.nio;

import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;
import java.nio.charset.Charset;
import java.util.Date;

public class WriterClient {
    public static void main(String[] args) {
        try {
            SocketChannel socketChannel = SocketChannel.open();
            socketChannel.connect(new InetSocketAddress("localhost",8080));

            //接收数据
            int count = 0;
            while (true){
                ByteBuffer allocate = ByteBuffer.allocate(1024 * 1024);
                count += socketChannel.read(allocate);
                System.out.println("接收值大小："+count);
                allocate.clear();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
